import { useNavigate } from 'react-router-dom'
import { Button, Form, Input } from 'antd'
import { LockOutlined, UserOutlined } from '@ant-design/icons'
import imgLogo from '@/assets/images/icon.svg'
// import bgPng from '../../../assets/images/bg.png'
import './login.styl'
import './index.less'

function Login() {
    // 创建路由钩子
    const navigate = useNavigate()

    const onFinish = (values) => {
        console.log('Received values of form: ', values)
        localStorage.setItem('userInfo', JSON.stringify(values))
        navigate('/home')
    }

    return (
        <div className="P-login">
            {/* <img src={imgLogo} alt="" className="logo" />
            <div className="ipt-con">
                <Input placeholder="账号" />
            </div>
            <div className="ipt-con">
                <Input.Password placeholder="密码" />
            </div>
            <div className="ipt-con">
                <Button type="primary" block={true} onClick={()=>{navigate('/home')}}>登录</Button>
            </div> */}
            <div className="wrap">
                <div className="box">
                    <img src={imgLogo} alt="" className="logo" />
                    <Form
                        name="login"
                        initialValues={{ remember: true }}
                        style={{ width: '100%' }}
                        onFinish={onFinish}
                        className="form"
                        requiredMark={false}
                        layout="vertical"
                    >
                        <Form.Item
                            name="username"
                            rules={[{ required: true, message: '请输入账号!' }]}
                            label="账号"
                        >
                            <Input prefix={<UserOutlined />} placeholder="请填写账号" />
                        </Form.Item>
                        <Form.Item
                            name="password"
                            rules={[{ required: true, message: '请输入密码!' }]}
                            label="密码"
                        >
                            <Input
                                prefix={<LockOutlined />}
                                type="password"
                                placeholder="请填写密码"
                            />
                        </Form.Item>

                        <Form.Item style={{ marginTop: '50px' }}>
                            <Button block type="primary" htmlType="submit">
                                登录
                            </Button>
                        </Form.Item>
                    </Form>
                </div>
            </div>
        </div>
    )
}

export default Login
